package com.dongbo.recorder.screenrecord.utils;

import android.text.TextUtils;



/**
 * description：
 * author：lutengxuan
 * CreateDate：2019-12-05
 */
public class DecryptOrNullBack {

    public static String judgeError(String response) {
        String bResponse = "";
        if (TextUtils.isEmpty(response)) {
            StringBuilder json = new StringBuilder();
            String message = "连接服务器失败！";
            json.append("{");
            json.append("\"showapi_res_error\":" + "\"" + message + "\",");
            json.append("\"showapi_res_code\":" + "\"" + -1 + "\",");
            json.append("}");
            bResponse = json.toString();
        } else {
            try {
                response = response.replace("\"", "");
                bResponse = new String(Base64.decode(response));
            } catch (Exception e) {
                StringBuilder json = new StringBuilder();
                String message = "返回值有误！";
                json.append("{");
                json.append("\"showapi_res_error\":" + "\"" + message + "\",");
                json.append("\"showapi_res_code\":" + "\"" + -1 + "\",");
                json.append("}");
                bResponse = json.toString();
            }
        }
        return bResponse;
    }

}
